﻿/* **************************************************************************
 *
 * Copyright 2007-2010 Jeff Hardy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * *************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Management.Client;

namespace NWSGI.ManagementClient
{
    public class NwsgiModule : Module
    {
        protected override void Initialize(IServiceProvider serviceProvider, Microsoft.Web.Management.Server.ModuleInfo moduleInfo)
        {
            base.Initialize(serviceProvider, moduleInfo);

            IControlPanel controlPanel = (IControlPanel)GetService(typeof(IControlPanel));

            ModulePageInfo info = new ModulePageInfo(this, typeof(NwsgiPage), "NWSGI Management", "Edit NWSGI settings", Resources.python_logo_16, Resources.python_logo_32);
            controlPanel.RegisterPage(ControlPanelCategoryInfo.ApplicationDevelopment, info);
            controlPanel.RegisterPage(new ModulePageInfo(this, typeof(PythonPathsPage), "Python Path Configuration"));
            controlPanel.RegisterPage(new ModulePageInfo(this, typeof(WsgiEnvironPage), "WSGI Environment Configuration"));
            controlPanel.RegisterPage(new ModulePageInfo(this, typeof(ScriptMappingsPage), "Script Mappings Configuration"));
        }

        protected override bool IsPageEnabled(ModulePageInfo pageInfo)
        {
            Connection conn = (Connection)GetService(typeof(Connection));
            return conn.ConfigurationPath.PathType == Microsoft.Web.Management.Server.ConfigurationPathType.Application;
        }
    }
}
